// Load all plugins.


#ifndef LIGHTY_MODULE_MANAGER_H
#define LIGHTY_MODULE_MANAGER_H

#include <SDL.h>
#include <SDL_mixer.h>
#include <SDL_ttf.h>
#include <SDL_image.h>
#include <GL/glew.h>
#include "Lighty_Debug.h"
#include "Lighty_Audio.h"

#define DEFAULT_CHUNKSIZE 1024

class Lighty_Init{
	
  public:
  
    static int Audio(){
        
      if(Mix_Init(MIX_INIT_MP3 | MIX_INIT_OGG)==-1){
  
        Lighty_PrintDebug("Module error : Can't load SDL_Mix!");
        return 1;
  
      }
  
      if(Mix_OpenAudio(MIX_DEFAULT_FREQUENCY, MIX_DEFAULT_FORMAT, 2, DEFAULT_CHUNKSIZE)==-1){

        Lighty_PrintDebug("Module error : Can't load MIX_OpenAudio !");
        return 1;
          
      }
  
      Mix_AllocateChannels(MaxChannel);      
	  return 0;
		
    }
	
	static int Graphics(){
	    
	  if(IMG_Init(IMG_INIT_PNG | IMG_INIT_JPG)==-1){
  
        Lighty_PrintDebug("Module error : Can't load image !");
        return 1;
  
      }
        
      if(SDL_Init(SDL_INIT_VIDEO)==-1){
    
	    Lighty_PrintDebug("Module error : Can't load video mod !");  
	    return 1;
  
      }
  
      if(TTF_Init()==-1){
  
        Lighty_PrintDebug("Module error : Can't load SDL_TTF !");
        return 1;
  
      }
	    
	  return 0;
		
	}
	
	static int GameUtils(){
		
	  if(SDL_Init(SDL_INIT_TIMER | SDL_INIT_GAMECONTROLLER | SDL_INIT_EVENTS)==-1){
    
	    Lighty_PrintDebug("Module error : Can't load GameUtils !");  
	    return 1;
  
      }
      
      return 0;
		
	}
	
	static int All(){
	
	  if(Audio()==1){
		  
	    return 1;
		  
	  }
	  
	  if(GameUtils()==1){
		  
	    return 1;
		  
	  }
	  
	  if(Graphics()==1){
		  
	    return 1;
		  
	  }
	  
	  return 0;
		
	}
	
};

class Lighty_Quit{
	
  public:
  
    static void Audio(){
		
	  Mix_CloseAudio();
      Mix_Quit();
		
	}
	
	static void GameUtils(){
		
	  SDL_QuitSubSystem(SDL_INIT_TIMER | SDL_INIT_GAMECONTROLLER | SDL_INIT_EVENTS);
		
	}
	
	static void Graphics(){
		
	  SDL_QuitSubSystem(SDL_INIT_VIDEO);
	  TTF_Quit();
      IMG_Quit();
		
	}
	
	static void All(){
		
	  Audio();	
	  GameUtils();
	  Graphics();
	  SDL_Quit();
		
	}
	
};

#endif
